﻿Public Class clsProdInfo
    ''' <summary>
    ''' 查询制品信息
    ''' </summary>
    ''' <param name="prod_id">生产编号</param>
    ''' <returns>制品信息</returns>
    Friend Function selectProdInfo(prod_id As String) As DataTable
        Dim szSql As String = ""
        szSql &= "SELECT * FROM sf.b_prod_info WHERE factory_id=? and prod_id = ? "
        Return DBacs.ExecuteSql(szSql, -1, "TS", prod_id)
    End Function

    Public Function getProdInfoById(prod_id As String, status As String) As DataTable
        Dim szSql As String = ""
        szSql &= "SELECT a.*,b.type_value FROM sf.b_prod_info a "
        szSql &= "left join sf.b_pgd_mes b on a.b_pgd_lx_details_sys_id = b.sys_id "
        szSql &= "WHERE a.factory_id = ? and a.prod_id = ? and a.status = ? "
        Return DBacs.ExecuteSql(szSql, -1, g_factory_id, prod_id, status)
    End Function

    Public Function updateProdInfo(prod_ids As String, oper As String) As Integer
        Dim sql As String = ""
        Dim rtn As Integer = 0
        DBacs.BeginTransaction()
        Try
            sql &= "update sf.b_prod_info set update_time = (SELECT CURRENT_TIMESTAMP(6)), jie_shou_ope = ?, jie_shou_dt = (SELECT CURRENT_TIMESTAMP(6)) "
            sql &= " where prod_id in ("
            sql &= prod_ids
            sql &= ") "
            DBacs.ExecuteUpdateSql(sql, -1, oper)
            DBacs.CommitTransaction()
        Catch ex As Exception
            DBacs.RollbackTransaction()
            rtn = -2
        End Try
        Return rtn
    End Function


End Class
